﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace HPAGMRestAPIWrapper
{
    /// <summary>
    ///  Release Backlog Item collection class
    /// </summary>
    public class AGMReleaseBacklogItems : AGMEntityCollection<AGMReleaseBacklogItem>
    {
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="connection">connection</param>
        public AGMReleaseBacklogItems(AGMConnection connection)
            : base(connection)
        {            
        }

        #region public methods
        #endregion
    }

    /// <summary>
    /// requirement class
    /// </summary>
    public class AGMReleaseBacklogItem : AGMEntity
    {
        #region private members
        #endregion       

        #region public Properties
        #endregion

        #region constructor
        #endregion

        #region public methods
        /// <summary>
        /// Update Release backlog item
        /// </summary>
        /// <returns></returns>
        public AGMReleaseBacklogItem Update()
        {
            if (Id <= 0) throw new Exception("Release backlog item Id cannot be empty.");

            return new AGMReleaseBacklogItems(Connection).Update(Id.Value, GetFieldsDictionary());
        }


        #region Task related
        public List<AGMProjectTask> GetAllTasks()
        {
            List<AGMProjectTask> tasks = new List<AGMProjectTask>();
            AGMProjectTasks pTasks = new AGMProjectTasks(Connection);
            List<AGMField> filters = new List<AGMField>();
            filters.Add(new AGMField { Name = "release-backlog-item-id", Value = Id.ToString() });
            tasks = pTasks.GetCollection(filters);

            return tasks;
        }
        #endregion
        #endregion

        #region private methods
        #endregion
    }
}
